import matplotlib.pyplot as plt
import numpy as np
from glob import glob
from scipy.misc import toimage
import matplotlib.pyplot as plt
import mpl_toolkits.mplot3d

# 2d合并
#
# working_path = "./tianchi/val/"
#
# file_list=glob(working_path+"val_output*/*images*.npy")
# mask_list=glob(working_path+"val_output*/*masks*.npy")
#
# mLen = len(file_list)
#
# if(mLen<1): exit(0)
#
# preview_images = np.array(np.load(file_list[0]))
# preview_masks = np.array(np.load(mask_list[0]))
# i = 1
# for i in range(mLen):
#     preview_images = np.vstack((preview_images, np.array(np.load(file_list[i]))))
#     preview_masks = np.vstack((preview_masks, np.array(np.load(mask_list[i]))))
#
# np.save("preview_images_merge.npy",preview_images)
# np.save("preview_masks_merge.npy",preview_masks)
#
# # 检测结果
# plt.subplot(1, 2, 1)
# plt.imshow(toimage(preview_images[100][0]),cmap='gray')
# plt.subplot(1, 2, 2)
# plt.imshow(toimage(preview_masks[100][0]),cmap='gray')
# plt.show()




#3D 合并
#
working_path = "./tianchi/3d/"
file_list=glob(working_path+"nodule-*-*.npy")
node_merge = []
for i in range(len(file_list)):
    if True:  #切换选择合成  True:(m,1,64,64,64,64) False:(m,64,64,64,64)
        temp = []
        temp.append(np.array(np.load(file_list[i])));
        node_merge.append(temp)
    else:
        node_merge.append(np.array(np.load(file_list[i])))

node_images = np.array(node_merge);
#node_images = np.rollaxis(node_images,1,5);  # 打开即可将 m,1,64,64,64 转成 m,64,64,64,1
np.save("node_merge.npy",node_images)

